<?php
	class cls_Usuarios
    {
        private $usu_codigo;
        private $usu_identificacion;
        private $usu_nombres;
        private $usu_apellidos;
        private $usu_edad;
        private $usu_estrato;
        private $archivo;
        private $gen_File;
        
        public function __construct()
        {
            $this->archivo = "controlador/plano_examen2.txt";    
            $this->gen_File = new gen_File();        
            $this->gen_File->setFilename($this->archivo);
        }
        
        public function Consultar()
        {
            $this->gen_File->open('r');
            $r = $this->gen_File->read(filesize($this->archivo));
            $this->gen_File->close();
            return $r;
        }
        
        public function Crear()
        {         
            $r = false;
            $filas = $this->gen_File->rows();
            if($filas > 0)
            {      
                $contenido = $this->Consultar();
                $lineas = explode("\n", $contenido); 
                foreach($lineas as $key => $valor){
                    if($key == $filas - 1){
                        $datos = explode(";", $valor);  
                        $this->usu_codigo = $datos[0] + 1;
                    }
                }
            }
            else{
                $this->usu_codigo = 1;
            }
            $this->gen_File->open('a+');
            $msg = 
                $this->usu_codigo . ";" .
                $this->usu_identificacion . ";" .
                $this->usu_nombres . ";" .
                $this->usu_apellidos . ";" .
                $this->usu_edad . ";" .
                $this->usu_estrato;
            $this->gen_File->setMsg($msg);
            if($this->gen_File->write() > 0){
                $r = true;
            }
            $this->gen_File->close();
            return $r;
        }
    
        public function setUsu_codigo($usu_codigo){
            $this->usu_codigo = $usu_codigo;
        }
        public function getUsu_codigo(){
            return $this->usu_codigo;
        }
        
        public function setUsu_identificacion($usu_identificacion){
            $this->usu_identificacion = $usu_identificacion;
        }
        public function getUsu_identificacion(){
            return $this->usu_identificacion;
        }
        
        public function setUsu_nombres($usu_nombres){
            $this->usu_nombres = $usu_nombres;
        }
        public function getUsu_nombres(){
            return $this->usu_nombres;
        }
        
        public function setUsu_apellidos($usu_apellidos){
            $this->usu_apellidos = $usu_apellidos;
        }
        public function getUsu_apellidos(){
            return $this->usu_apellidos;
        }
        
        public function setUsu_edad($usu_edad){
            $this->usu_edad = $usu_edad;
        }
        public function getUsu_edad(){
            return $this->usu_edad;
        }
        
        public function setUsu_estrato($usu_estrato){
            $this->usu_estrato = $usu_estrato;
        }
        public function getUsu_estrato(){
            return $this->usu_estrato;
        }
    }
?>